import QtQuick 2.14
import QtQuick.Window 2.14
import QtQuick.Layouts 1.12
import QtQuick.Controls 2.14
import QtQuick.Controls.Material 2.12

import "qrc:/_context/Basic"
import "qrc:/_context/CusCheckBox"
import "qrc:/_context/CusInput"
import "qrc:/_context/CusGroupBox"
import "qrc:/_context/Container"
import "qrc:/_context/CusButton"

Item {
    Rectangle{
        id: rec;
        property int fileFlag: 0;

        ColumnLayout{
            anchors.fill: parent;
            anchors.margins: 20;
            spacing: 25;

            RowLayout{
                spacing: 20;

                YaheiText{
                    text: "请选择Modbus通讯方式：";
                }

                CusCheckBox{
                    id: _tcp;
                    text: "TCP";

                    checked: true;

                    onCheckedChanged: {
                        if(checked == true){
                            checkable = false;

                            _rtu.checked = false;
                            _rtu.checkable = true;

                            rec.fileFlag = 0;
                        }
                    }
                }

                CusCheckBox{
                    id: _rtu;
                    text: "RTU";

                    checked: false;

                    onCheckedChanged: {
                        if(checked == true){
                            checkable = false;

                            _tcp.checked = false;
                            _tcp.checkable = true;

                            rec.fileFlag = 1;
                        }
                    }
                }
            }


            RowLayout{
                spacing: 15;

                CusButton{
                    text: "加载配置文件";

                    onClicked: {
                        // console.log(rec.fileFlag);
                        XLSX.loadExcel(rec.fileFlag);
                    }
                }

                CusButton{
                    text: "自动配置Modbus";

                    onClicked: {

                    }
                }
            }
        }


    }
}
